<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html class="zh-cn zh cn" lang="zh-cn"> 
<head>
	<%@ include file="../head.jsp" %>
	<link rel="stylesheet" type="text/css" href="/resource/css/validationEngine.jquery.css" />
    <link rel="stylesheet" type="text/css" href="/resource/css/template.css" />
	<script src="/resource/js/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
	<script src="/resource/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
</head>
<body class="vday home"> 
	<div id="page">
	<%@ include file="../global_navi.jsp" %>
	<%@ include file="../aos_header.jsp" %><!-- 如果需要查询，要自定义aos_header --> 
  	<%@ include file="../guide.jsp" %><!-- 动态向导栏，需要后台 -->
		<div id="primary">
			<div id="primary_main" role="main">
				<div class="box product-shelf">
					<div class="box-content clearfix">
						<form id="addressForm" method="POST" action="/setting/modify" onsubmit="validateSettingForm();">
						<table>
							<tbody>
								<!-- 
								<tr>
									<td width="100px;"></td>
									<th><span>模板编号：</span></th>
									<td>${setting.id}</td>
									<td width="100px;"></td>
								</tr>
								-->
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr>
									<td width="100px;"></td>
									<th style="text-align: left;"><span>名称：</span></th>
									<td><input maxlength="20" type="text" value="${setting.name}" size="37" name="setName" id="setName" class="validate[required,funcCall[checkSp]]"/></td>
								</tr>
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr>
									<td></td>
									<th><span><font color="red">价格底线：</font></span></th>
									<fmt:formatNumber value="${setting.baseLine}" var="baseLine" maxFractionDigits="0"></fmt:formatNumber>
									<td><input maxlength="3" type="text" value="${baseLine}" size="35" name="setPrice" id="setPrice" class="validate[required,custom[integer],max[100],min[0]]"/>%</td>
								</tr>
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr>
									<td></td>
									<th><span>最大次数：</span></th>
									<td><input maxlength="2" type="text" value="${setting.maxCount}" size="37" name="maxCount" id="maxCount" class="validate[required,custom[integer],min[0]]"/></td>
								</tr>
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr>
									<td></td>
									<th><span>智能强度：</span></th>
									<td><input id="amount" type="text" value="${setting.aI}" size="37" name="amount" id="amount" class="validate[required,min[1],max[10]]" readonly="readonly"/></td>
								</tr>
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr>
									<td></td>
									<td colspan="3"><div id="slider-range-max"></div></td>
									<td></td>
								</tr>
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr>
									<td></td>
									<th style="vertical-align: top;"><span>低于底线：</span></th>
									<td>
										<textarea rows="3" cols="45" name="firstDialog" id="firstDialog" class="validate[required]" maxlength="256">${setting.firstDialogue}</textarea>
										<!-- <input type="text" value="${setting.firstDialogue}" size="20" /> -->
									</td>
								</tr>
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr>
									<td></td>
									<th style="vertical-align: top;"><span>高于原价：</span></th>
									<td>
										<!--<input type="text" value="${setting.secondDialogue}" size="20" name="secondDialog" />-->
										<textarea rows="3" cols="45" name="secondDialog" id="secondDialog" class="validate[required]" maxlength="256">${setting.secondDialogue}</textarea>
									</td>
								</tr>
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr>
									<td></td>
									<th style="vertical-align: top;"><span>接受砍价：</span></th>
									<td>
										<!-- <input type="text" value="${setting.thridDialogue}" size="20" /> -->
										<textarea rows="3" cols="45" name="thirdDialog" id="thirdDialog" class="validate[required]" maxlength="256">${setting.thridDialogue}</textarea>
									</td>
								</tr>
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr>
									<td></td>
									<th style="vertical-align: top;"><span>不接受砍价：</span></th>
									<td>
										<!-- <input type="text" value="${setting.forthDialogue}" size="20" /> -->
										<textarea rows="3" cols="45" name="forthDialog" id="forthDialog" class="validate[required]" maxlength="256">${setting.forthDialogue}</textarea>
									</td>
								</tr>
								<tr><td colspan="3">&nbsp;</td></tr>
							</tbody>
						</table>
						
						<input type="hidden" name="setId" value="${setting.id}" />
						
						<c:if test="${editting}">
							<div style="padding-left:55%;padding-bottom: 15px;">
								<input type="reset" value="重置"/>&nbsp;&nbsp;
								<input type="submit" value="提交"/>
							</div>
						</c:if>
						<c:if test="${!editting}">
							<div style="padding-left:48%;padding-bottom: 15px;" id="editDiv">
								<input type="button"" id="editButton" value="编辑"/>&nbsp;&nbsp;
								<input type="button" id="delButton" value="删除"/>&nbsp;&nbsp;
								<input type="button" value="返回" onclick="javascript:history.back();"/>
							</div>
						</c:if>
						</form>
					</div>
					<div class="top-corners"></div>
					<div class="bottom-corners"></div>
				</div>
				<ul class="home-page-banners clearfix"></ul>
			</div>
			<div id="secondary" class="rail">
				<div role="navigation" aria-label="New Items" class="box navigation-list new-to-store">
					<div class="title-bar">
						<h2> 操作</h2>
					</div>
					<div class="box-content clearfix">
						<div class="list_content">
						<ul>
							<li><a href="/setting/list" onclick="singleLoading();">返回模板首页</a></li>
						</ul>
						</div>
					</div>
					<div class="bottom-corners"></div>
				</div>
				<div class="box navigation-list top-sellers"></div>
				<div class="module footerblock"></div>
			</div>
		</div>
	<%@ include file="../left_navi.jsp" %>
	<%@ include file="../footer.jsp" %>
	</div>
<script type="text/javascript">
jQuery(document).ready(function(){
	//设置当前路径
	jQuery("#breadcrumb").append('<li><span id="tmpTitle">:&nbsp;&nbsp;模板察看</span></li>');

	var tmpAI = ${setting.aI};
	var isEdit = ${editting};
	jQuery( "#slider-range-max" ).slider({
		range: "max",
		min: 1,
		max: 10,
		value: tmpAI,
		slide: function(event, ui) {
			jQuery("#amount").val(ui.value);
		}
	});
	jQuery("#amount").val(jQuery("#slider-range-max").slider("value"));

	if (isEdit)
	{
		jQuery("#addressForm").validationEngine();
		jQuery("#tmpTitle").html(":&nbsp;&nbsp;模板编辑");
		jQuery("#setName").attr("CONTENTEDITABLE", "true");
		jQuery("#setPrice").attr("CONTENTEDITABLE", "true");
		jQuery("#maxCount").attr("CONTENTEDITABLE", "true");
		//jQuery("#amount").attr("CONTENTEDITABLE", "true");
		jQuery("#firstDialog").attr("CONTENTEDITABLE", "true");
		jQuery("#secondDialog").attr("CONTENTEDITABLE", "true");
		jQuery("#thirdDialog").attr("CONTENTEDITABLE", "true");
		jQuery("#forthDialog").attr("CONTENTEDITABLE", "true");
	}
	else
	{
		jQuery("#setName").attr("CONTENTEDITABLE", "false");
		jQuery("#setPrice").attr("CONTENTEDITABLE", "false");
		jQuery("#maxCount").attr("CONTENTEDITABLE", "false");
		//jQuery("#amount").attr("CONTENTEDITABLE", "false");
		jQuery("#firstDialog").attr("CONTENTEDITABLE", "false");
		jQuery("#secondDialog").attr("CONTENTEDITABLE", "false");
		jQuery("#thirdDialog").attr("CONTENTEDITABLE", "false");
		jQuery("#forthDialog").attr("CONTENTEDITABLE", "false");
	}
	//edit
	jQuery("#editButton").click(function(){
		jQuery("#tmpTitle").html(":&nbsp;&nbsp;模板编辑");
		jQuery("#addressForm").validationEngine();

		jQuery("#setName").attr("CONTENTEDITABLE", "true");
		jQuery("#setPrice").attr("CONTENTEDITABLE", "true");
		jQuery("#maxCount").attr("CONTENTEDITABLE", "true");
		//jQuery("#amount").attr("CONTENTEDITABLE", "true");
		jQuery("#firstDialog").attr("CONTENTEDITABLE", "true");
		jQuery("#secondDialog").attr("CONTENTEDITABLE", "true");
		jQuery("#thirdDialog").attr("CONTENTEDITABLE", "true");
		jQuery("#forthDialog").attr("CONTENTEDITABLE", "true");

		jQuery("#editDiv").css("padding-left","55%");
		jQuery("#editDiv").html('<input type="reset"" value="重置"/>&nbsp;&nbsp;<input type="submit" value="提交"/>');
	});
});
function validateSettingForm()
{
    if( jQuery("#addressForm").validationEngine('validate'))
    {
        jQuery("#nyroDiv a").nmCall();
    }
}
function singleLoading(){
    jQuery("#nyroDiv a").nmCall();
}
function checkSp(field, rules, i, options)
{
    var invalidChar=/^[\|"'<>&\^\?\*~\{\}\[\]\+\-\$()#!！@？“‘%（）……￥`·_\-—=【】\\;；’”，《》,.。、:：\/]+$/;
    if (invalidChar.test(field.val())) 
    {
        return "* 不能输入特殊字符,只能包括字母、数字或者汉字";
    }
}
</script>
</body>
</html>